import java.util.Stack;

public class MyQueue1 {

    private Stack<Integer>stack1=new Stack<>();
    private Stack<Integer>stack2=new Stack<>();

    public MyQueue1() {

    }
    //将元素 x 推到队列的末尾
    public void push(int x) {
        stack1.push(x);
    }
    //从队列的开头移除并返回元素
    public int pop() {
        if(empty())return -1;
        while (stack1.size()-1>0){
            stack2.push(stack1.pop());
        }
        int tmp=stack1.pop();
        while (stack2.size()>0){
            stack1.push(stack2.pop());
        }
        return tmp;
    }
    //返回队列开头的元素
    public int peek() {
        if(empty())return -1;
        while (stack1.size()-1>0){
            stack2.push(stack1.pop());
        }
        int tmp=stack1.peek();
        stack2.push(stack1.pop());
        while (stack2.size()>0){
            stack1.push(stack2.pop());
        }
        return tmp;
    }
    //如果队列为空，返回 true ；否则，返回 false
    public boolean empty() {
        if(stack1.size()==0&&stack2.size()==0){
            return true;
        }
        return false;
    }
}
